import React, { useState } from "react";
import Item1 from './Item1';
import Item2 from './Item2';

function Box() {
    const [num, setNum] = useState(0);
    const [time, setTime] = useState(new Date().getTime());
    const changeNum = () => {
        setNum(num => num + 1)
    }
    const changeTime = () => {
        setTime(time => new Date().getTime())
    }
    return (
        <div className='wrapper wrapper1'>
            <h2 className='display-4'>memo的基本使用</h2>
            <button className="btn btn-primary" onClick={changeNum}>更改num</button>
            <button className="ml-3 btn btn-danger" onClick={changeTime}>更改time</button>
            <Item1 num={num} />
            <Item2 time={time} />
        </div>
    )
}

export default Box;